package cn.tedu.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

/**
 * 一个人可以说多个话
 */
public class ServerMoreLine {
    public static void main(String[] args) throws IOException {
        ServerSocket serversocket = new ServerSocket(8888);

        try {
            System.out.println("等待连接");
            Socket socket = serversocket.accept();
            System.out.println("连接成功");
            InputStream in = socket.getInputStream();
            InputStreamReader isr = new InputStreamReader(in, StandardCharsets.UTF_8);
            BufferedReader br = new BufferedReader(isr);
            String line = null;
            while((line= br.readLine())!=null){
                System.out.println(line);
            }
            br.close();
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
